package org.gaaidou.ptarmigan.springboot.functional.config;

import org.gaaidou.ptarmigan.springboot.core.spring.DynamicBeanDefinition;
import org.gaaidou.ptarmigan.springboot.core.spring.DynamicBeanDefinitionRegistry;
import org.gaaidou.ptarmigan.springboot.functional.service.impl.MultipleBeanServiceImpl;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import java.util.List;

@Configuration
public class MultipleBeanConfig extends DynamicBeanDefinitionRegistry {
    @Override
    protected void createBean(Environment env, List<DynamicBeanDefinition> definitions) {
        for (int i = 0; i < 10; i++) {
            String beanName = String.format("multiple_svc_%s", i);
            definitions.add(new DynamicBeanDefinition(beanName, new MultipleBeanServiceImpl(beanName)));
        }
    }
}
